package mud;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/** A virtual world */
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class World {

    /** the rooms of which this world is composed */
    @XmlElement(name="room")
    private final List<Room> rooms;

    /** the different races of the world */
    @XmlElement(name="race")
    private List<Race> races;
    
    /**
     * Constructor
     */
    public World() {
        rooms = new ArrayList<>();
    }
    
    /**
     * @return the exit that serves as the initial entrance for newly created
     * player units
     */
    public Exit getNewPlayerEntrance() {
        return rooms.get(0).getExits().get(0);
    }
    
    @Override 
    public String toString() {
        return getClass().getSimpleName() + "["
            + "rooms=" + rooms + ","
            + "races=" + races + "]";
    }

    /**
     * @return the different races of the world
     */
    public List<Race> getRaces() {
        return races;
    }
}
